package main

import "fmt"

/**
  Go 接口:
  	一个对象只要包含接口中的方法，那么就实现了这个接口
	空接口可以作为任何类型数据的容器

 */
func main() {
	var phone Phone

	phone = new(NokiaPhone)
	phone.call()
	phone.send()

	phone = new(IPhone)
	phone.call()
	phone.send()

	//testSwitch(1)

}
type Phone interface {
	call()
	send()
}

type NokiaPhone struct {
}

func (nokiaPhone NokiaPhone) call() {
	fmt.Println("I am Nokia, I can call you!")
}

func (nokiaPhone NokiaPhone) send() {
	fmt.Println("I am Nokia, I can send you!")
}

type IPhone struct {
}

func (iPhone *IPhone) call() {
	fmt.Println("I am iPhone, I can call you!")
}

func (iPhone *IPhone) send() {
	fmt.Println("I am iPhone, I can send you!")
}

/**
  类型断言
 */
func testSwitch(a interface{}){
	switch v := a.(type) {
		case int:
			fmt.Printf("a is int, value:%d\n", v)
		default:
			fmt.Println("default ")

	}
}